package com.eigaland.change_machine.business.show

import android.util.Log
import androidx.databinding.ObservableField
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import com.eigaland.change_machine.business.movielist.MovieListFragment
import com.eigaland.change_machine.business.movielist.MovieListFragmentVM
import com.eigaland.change_machine.util.UserManager
import movie6.posprintercept2.extensions.customLaunch
import java.util.logging.Logger

public class ShowListFragmentVM : MovieListFragmentVM() {

    var showListFragmentRepository = ShowListFragmentRepository()

    var dateListVM = MutableLiveData<List<ShowListDateVM>>()

    var showListVM = MutableLiveData<List<List<ShowListItemVM>>>()

    var curMovieName = ObservableField<String>("")


    fun loadDateList(){
        customLaunch({
            dateListVM.postValue(showListFragmentRepository.getDateList().dateList) //  post the date
        },{

        })
    }


    fun loadShowListWith(movieId:String,curDate:String){
        progressLoadingStatus.postValue(true)
        customLaunch({

          var result = showListFragmentRepository.getShowList( movieId,UserManager.cinemaId,curDate)
            showListVM.postValue(result.showList)
          progressLoadingStatus.postValue(false)

        },{
            progressLoadingStatus.postValue(false)
            it.printStackTrace()
        })
    }

}
